package cfdt.ldl.trade.api.feign.fallback;

import cfdt.common.enums.CommonCodeEnum;
import cfdt.common.vo.ObjectBaseResponse;
import cfdt.ldl.trade.api.feign.TradeFeign;
import cfdt.ldl.trade.api.request.AddLawyerTradeRequest;
import cfdt.ldl.trade.api.request.GetLawyerInfoListTradeRequest;
import cfdt.ldl.trade.api.response.GetLawyerInfoListTradeResponse;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 
 * 黑名单校验-FallBack
 *
 * <pre>
 * Modify Information:
 * Author       Date          Description
 * ============ ============= ============================
 * wangxiao      2021年8月16日上午9:51:24      创建 FallBack
 *
 * </pre>
 */
@Component
public class TradeFallBack implements FallbackFactory<TradeFeign> {
    
    private final Logger logger = LoggerFactory.getLogger(getClass().getName());

    @Override
    public TradeFeign create(Throwable cause) {
        logger.error("请求交易中心服务异常", cause);
        return new TradeFeign() {
            @Override
            public ObjectBaseResponse<GetLawyerInfoListTradeResponse> getLawyerInfoList(GetLawyerInfoListTradeRequest request) {
                return ObjectBaseResponse.error(CommonCodeEnum.CODE_1001);
            }

            @Override
            public ObjectBaseResponse addLawyer(AddLawyerTradeRequest request) {
                return ObjectBaseResponse.error(CommonCodeEnum.CODE_1001);
            }

        };
    }

}
